package com.snake.design.pe.factory;

/**
 * 
 * 简单工厂模式就是方法传个类名工厂给你创建个对象，工厂可以给你做很多初始化工作不需要自己做
 *
 */
public class SimpleFactory {
	public Object createClass(Class<?> a) {
		if (a.getName().equals(A.class.getName())) {
			A a1 = new A();
			a1.setName("韩信1打5");
			return a1;

		} else {
			return new B();
		}
	}

	public static void main(String[] args) {
		SimpleFactory s = new SimpleFactory();
		A createClass = (A) s.createClass(A.class);
		System.out.println(createClass.getName());
	}
}

class A {
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}

class B {

}
